#include<stdio.h>
long htod(char s[])
{
	int i;
	long p=0 ; 
	for(i=0;s[i]!='\0';i++)
	if(s[i]>='0' && s[i]<='9')
	p=p*16+s[i]-'0';
	else if(s[i]>='a' && s[i]<='f')
	p=p*16+10+s[i]-'a' ;
	else
	p=p*16+10+s[i]-'A';
	return p;
}

int main()
{
	char s[128];
	long p;
	gets(s);
	p=htod(s);
	printf("%ld",p);
	return 0;
}
